//index.js
//获取应用实例
const app = getApp()
const Pager = require('components/aotoo/core')
let lib = Pager.lib
const util = require('../../utils/util.js')

Pager({
  data: {
    search: Pager.item({
      title: [{title: ' ', itemClass: 'icon-search'}, {title: '搜索', itemClass: 'ml-minor'}],
      titleClass: 'flex-row-center-center',
      itemClass: 'ss-search-false',
      aim: 'onSearch'
    }),
    pages: Pager.list({
      data: adapter([1,2,3,1,2,3, 1,2,3,1,2,3, 1,2,3,1,2,3]),
      itemClass: 'slip-item',
      itemMethod: {
        touchstart(){},
        //方式一 ：滑动操作按钮。直接在这先写好  方式二：按钮写在结构上
        touchoption: {
          slip: {
            autoDelete: false,
            menuWidth: ['90', '75', '60'],
            slipLeft: [
              { title: '标为未读', itemClass: 'delete-item success', aim(e, param, inst) { console.log('===== ttt', inst)} },
              { title: '不显示', itemClass: 'delete-item warn', aim(e, param, inst) { console.log('===== ttt', inst)} },
              { title: '删除', itemClass: 'delete-item fail', aim(e, param, inst) { 
                const parent = inst.parent()
                parent.delete()
              }},
            ],
          }
        },
      },
    })
  },
  onReady() {
    util.insertScreenAD('adunit-7248d31d9572f228')
  },
  onLoad() {
  },
  onSearch() {
    wx.navigateTo({
      url: '../search/index'
    })
  }
})

function adapter(data) {
  return data.map((item, ii) => {
    return {
      title: [
        {
          img: { src: '/images/pay.jpg', itemClass: 'item-pic'}
        },
        {
          title: [
            {title: [{title: '没什么大不了， 死不了就还好_'+ii, itemClass: 'item-title'}, {title: '13:14', itemClass: 'item-dot'}], titleClass: 'flex-row-between-center'},
            {title: '天涯无归路，黄泉断魂人。...', itemClass: 'item-desc'}
          ],
          itemClass: 'hei-p100',
          titleClass: 'hei-p100 flex-column-around'
        }
      ],
      titleClass: 'slip-item-title'
    }
  })
}

//第一种方式 ：滑动操作按钮。直接在写在遍历的数据里
// function adapter(data) {
//   return data.map(item => {
//     return {
//       title: [
//         {
//           img: { src: '/images/pay.jpg', itemClass: 'item-pic'}
//         },
//         {
//           title: [
//             {title: [{title: '没什么大不了， 死不了就还好', itemClass: 'item-title'}, {title: '13:14', itemClass: 'item-dot'}], titleClass: 'flex-row-between-center'},
//             {title: '天涯无归路，黄泉断魂人。...', itemClass: 'item-desc'}
//           ],
//         }
//       ],
//       titleClass: 'slip-item-title',
//       touchoption: {
//         slip: {
//           autoDelete: false,
//           menuWidth: ['90', '75', '60'],
//           slipLeft: [
//             { title: '标为未读', itemClass: 'delete-item success', aim(e, param, inst) { console.log('===== ttt', inst)} },
//             { title: '不显示', itemClass: 'delete-item warn', aim(e, param, inst) { console.log('===== ttt', inst)} },
//             { title: '删除', itemClass: 'delete-item fail', aim(e, param, inst) { 
//               const parent = inst.parent()
//               parent.delete()
//             }},
//           ],
//         }
//       },
//     }
//   })
// }